#!/bin/bash
# Project: bash_tools
# Filename: demo.vector.sh
# Author: Wojciech Ornowski
# Date: 2012-06-14
# Version: 1.0
# License: 
#
# Describe: Script contains demonstration of vector.lib.sh usage.
#
# Usage: demo.vector.sh [-lib vector.lib.sh]
#	 [-lib] showing help of included library
#
# Exitcodes: -

#INCLUDE
. vector.lib.sh

vec_new names "John Junior" Max Justine #Create vector "names" with 3 elements
vec_add names Stefan Mario Ive Andreas	#Add 4 elements to existing vector "names"
vec_getall names			#Display all elements from vector "names"
vec_set names 3 "Stefan Zajkowski"	#Replace 4th element (index 3) "Stefan" with given element "Stefan Zajkowski"
vec_get names 4				#Display 5th element (index 4) from vector "names"
vec_len names				#Display number of elemetns in vector "names"
vec_new team				#Create empty vector "team"
vec_clone names team			#Copy all elements from vector "names" to vector "team"
vec_del team 1				#Delete secound element from vector "team"
vec_del team `vec_getid team Justine`	#Get index of element "Justine" in vector "team" and delete it
while vec_shift team; do		#
  vec_get team				#Display vector "team" element by element using vec_shift and vec_get function
done					#
variable="John Junior"							#
if vec_contain names "$variable"; then					#
  echo "Element \"$variable\" is in vector \"names\""			#Check and display information if element from variable
else									#is in the vector.
  echo "There is no element: \"$variable\" in vector \"names\""		#
fi									#

# vec_new numbers				#
# for a in {1..1000}; do			#
# vec_add numbers "$a"			#
# done					#How fast is it for 1000 elements?
# date					#
#  vec_get numbers 999			#
# date					#
